﻿<UserControl x:Class="Sando.UI.View.SearchView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:viewmodel="clr-namespace:Sando.UI.ViewModel"
             xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
             xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
             xmlns:converters="clr-namespace:Sando.UI.View.Search.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/UI;component/Base/StyleDictionary.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
            <converters:SwumTypeToColorConverter x:Key="SwumTypeToColorConverter"/>
            <converters:BackgroundConverter x:Key="BackgroundConverter" />
            <Style x:Key="FixedWidthLBStyle" TargetType="ListBoxItem">
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="HorizontalAlignment" Value="Stretch"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <!--<MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsMouseOver" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMouseOverBackgroundGradientKey}}"/>
                                </MultiTrigger>-->
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="Selector.IsSelectionActive" Value="False"/>
                                        <Condition Property="IsSelected" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMouseOverBackgroundGradientKey}}"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="Selector.IsSelectionActive" Value="True"/>
                                        <Condition Property="IsSelected" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMouseDownBackgroundGradientKey}}"/>
                                </MultiTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <!--<Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="IsSelected" Value="True"/>
                    </Trigger>
                </Style.Triggers>-->
            </Style>
        </ResourceDictionary>        
    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>            
            <RowDefinition Height="17"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="7" MinHeight="7"/>
            <RowDefinition Height="15" MinHeight="15"/>
            <RowDefinition Height="15" MinHeight="15"/>
            <RowDefinition Height="Auto" MinHeight="15"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Margin="5,0,5,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="83">
                </ColumnDefinition>
                <ColumnDefinition Width="*">
                </ColumnDefinition>

            </Grid.ColumnDefinitions>

            <TextBox Margin="-3,0,0,0"  Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}" BorderThickness="0" FontSize="11" FontStyle="Italic" Background="{Binding Path=Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" IsReadOnly="True"   Grid.Row="0"  HorizontalAlignment="Left" 
                     Width="127"  Grid.Column="0" Height="Auto"  
                     KeyboardNavigation.IsTabStop="False" TextWrapping="Wrap" Text="Indexed Folders:" Grid.ColumnSpan="2"/>


            <TextBox KeyboardNavigation.IsTabStop="False"   BorderThickness="0" IsReadOnly="True" Grid.Column="1" Name="IndexingList" Margin="2,0,5,1" FontSize="11" FontStyle="Italic" HorizontalAlignment="Stretch" Text="{Binding Path=CurrentIndexedFile.FilePath}"
                      KeyDown="IndexingList_KeyDown" PreviewMouseDown="IndexingList_MouseButtonDown"
                Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}" ToolTip="Specify folders to index for open solution" Grid.ColumnSpan="2">
                <TextBox.Background>
                    <Binding Path="OpenSolutionPaths" Mode="OneWay" UpdateSourceTrigger="PropertyChanged" Converter="{StaticResource BackgroundConverter}"/>
                </TextBox.Background>
            </TextBox>
            <Popup Name="CurrentlyIndexingFoldersPopup" Placement="Bottom" PlacementTarget="{Binding ElementName=IndexingList}" StaysOpen="True" IsOpen="False" Width="Auto">
                <Grid  IsEnabled="{Binding IsIndexFileEnabled}" Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolboxBackgroundKey   }}">
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition Height="40"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Border Grid.RowSpan="2" BorderBrush="Black" BorderThickness="1,1,1,1" CornerRadius="0,0,5,5"></Border>
                    <Grid Margin="3">
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition Height="40"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition Width="70"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <ListBox ItemsSource="{Binding Path=IndexedFiles}" SelectedItem="{Binding SelectedIndexedFile}" Height="120" VerticalAlignment="Top" Width="236" >
                                <ListBox.ItemTemplate>
                                    <DataTemplate DataType="{x:Type viewmodel:IndexedFile}">
                                        <TextBlock Text="{Binding FilePath}" ></TextBlock>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                            <StackPanel Grid.Column="1">
                                <Button Margin="5" Width="60" Height="25" Command="{Binding AddIndexFolderCommand}">Add</Button>
                                <Button Margin="5" Width="60" Height="25" Command="{Binding RemoveIndexFolderCommand}">Remove</Button>
                            </StackPanel>
                        </Grid>
                        <Grid Grid.Row="1" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition Width="80"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Border BorderBrush="Black" BorderThickness="0,0,0,1" Grid.ColumnSpan="2"></Border>
                            <TextBox Margin="5" Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}" Height="25" Width="220" 
                                     Text="{Binding SelectedIndexedFile.FilePath, UpdateSourceTrigger=PropertyChanged}"
                                     ToolTip="{Binding SelectedIndexedFile.FilePath}">

                            </TextBox>
                            <Button Height="25" Width="60" Grid.Column="1" Click="BrowserButton_Click" IsEnabled="{Binding IsBrowseButtonEnabled}">Browser</Button>
                        </Grid>

                    </Grid>

                    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Name="OKButton" Margin="5" Width="60" Height="25" Click="OKButton_Click" Command="{Binding ApplyCommand}">OK</Button>
                        <Button Name="CancelButton" Margin="5" Width="60" Height="25" Click="CancelButton_Click" Command="{Binding CancelCommand}">Cancel</Button>
                    </StackPanel>
                </Grid>
            </Popup>
        </Grid>
        <Grid Grid.Row="1" Margin="5,0,5,0" Grid.Column="0">

            <!-- Top Part: Query -->
            <controls:AutoCompleteBox 
                    Name="SearchBox"
                        GotFocus="SearchBox_GotFocus"
                        KeyUp="SearchBox_OnKeyUpHandler"
                        Loaded="SearchBox_Loaded"
                        LostFocus="SearchBox_LostFocus"   
                        Populating="SearchBox_Populating"
                    FilterMode="None"
                    MinimumPrefixLength="0"
                    ValueMemberPath="Query"
                        Background="{DynamicResource {x:Static vsfx:VsBrushes.SearchBoxBackgroundKey}}"  
                        BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.SearchBoxBorderKey}}"
                        Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}"
                    Height="25"
                    HorizontalAlignment="Stretch"
                    ItemContainerStyle="{StaticResource FixedWidthLBStyle}"
                    Margin="0,0,0,0"
                    MaxDropDownHeight="500" 
                    ToolTipService.ShowDuration="2000"
                    VerticalAlignment="Top" 
                    >
                <controls:AutoCompleteBox.ToolTip>
                    <StackPanel>
                        <TextBlock>Add ALL relevant words (i.e., Google-style query)</TextBlock>
                        <TextBlock>Keyboard shortcut: Ctrl+Shift+F</TextBlock>
                    </StackPanel>
                </controls:AutoCompleteBox.ToolTip>
                <controls:AutoCompleteBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Query}">
                            <TextBlock.Style>
                                <Style TargetType="TextBlock">
                                    <Setter Property="Padding" Value="0,2,8,2"/>
                                    <Setter Property="Margin" Value="16,0,0,0"/>
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                    <Setter Property="Foreground">
                                        <Setter.Value>
                                            <MultiBinding  Mode="OneWay" Converter="{StaticResource SwumTypeToColorConverter}">
                                                <Binding Path="." Mode="OneWay" RelativeSource="{RelativeSource FindAncestor, AncestorType=ListBoxItem}"/>
                                                <Binding Path="IsSelected" Mode="OneWay" RelativeSource="{RelativeSource FindAncestor, AncestorType=ListBoxItem}"/>
                                            </MultiBinding>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                    </DataTemplate>
                </controls:AutoCompleteBox.ItemTemplate>
                <controls:AutoCompleteBox.Template>
                    <ControlTemplate TargetType="{x:Type controls:AutoCompleteBox}">
                        <Grid Opacity="{TemplateBinding Opacity}">
                            <Border Name="AutoCompleteSearchBoxBorder"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Margin="0"
                                    Padding="0"
                                    >
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="{TemplateBinding Height}"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="25"/>
                                    </Grid.ColumnDefinitions>

                                    <TextBox Grid.Column="0"
                                        x:Name="Text"
                                            Background="{TemplateBinding Background}"
                                            Foreground="{TemplateBinding Foreground}"
                                        IsTabStop="True"
                                        BorderBrush="Transparent"
                                        BorderThickness="0"
                                        Margin="2,0,0,0"
                                        Padding="0"
                                             HorizontalContentAlignment="Left"
                                             VerticalContentAlignment="Center"
                                        Style="{TemplateBinding TextBoxStyle}"
                                        />
                                    <Button Grid.Column="1"
                                        Name="SearchButton"
                                        Command="{Binding SearchCommand}"
                                        CommandParameter="{Binding ElementName=SearchBox, Path=Text}"
                                            Content="&#xf002;"
                                            FontFamily="pack://application:,,,/UI;component/Resources/#FontAwesome"
                                            FontSize="14"
                                            HorizontalAlignment="Stretch"
                                            VerticalAlignment="Stretch"
                                        Background="{TemplateBinding Background}"
                                        Foreground="{TemplateBinding Foreground}"
                                            BorderBrush="Transparent"
                                            BorderThickness="0"
                                            Margin="0"
                                            Padding="0"
                                        >
                                        <Button.LayoutTransform>
                                            <RotateTransform Angle="90"/>
                                        </Button.LayoutTransform>
                                        <Button.Template>
                                            <ControlTemplate TargetType="{x:Type Button}">
                                                <Border x:Name="ButtonBorder"                                                
                                                        Background="{TemplateBinding Background}"
                                                        BorderBrush="{TemplateBinding BorderBrush}"
                                                        BorderThickness="{TemplateBinding BorderThickness}"
                                                        Margin="0"
                                                        >
                                                    <ContentPresenter x:Name="ButtonContentPresenter"
                                                                      Content="{TemplateBinding Content}"
                                                                      Margin="{TemplateBinding Padding}"
                                                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                                </Border>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Setter TargetName="ButtonBorder" Property="Background" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarHoverOverSelectedKey}}"/>
                                                    </Trigger>
                                                    <Trigger Property="IsPressed" Value="True">
                                                        <Setter TargetName="ButtonBorder" Property="Background" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMouseDownBackgroundGradientKey}}"/>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>
                                </Grid>
                            </Border>
                            <Popup x:Name="Popup" Visibility="Collapsed" MaxWidth="{Binding ElementName=AutoCompleteSearchBoxBorder, Path=ActualWidth}" MinWidth="{Binding ElementName=AutoCompleteSearchBoxBorder, Path=ActualWidth}">
                                <Grid>
                                    <Border BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMenuBorderKey}}"
                                            BorderThickness="1"
                                            CornerRadius="0"
                                            HorizontalAlignment="Stretch"
                                            Opacity="1"
                                            Padding="0"
                                            Background="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMenuBackgroundGradientKey}}"
                                            >
                                        <Border.RenderTransform>
                                            <TransformGroup>
                                                <TranslateTransform X="-1" Y="-1"/>
                                            </TransformGroup>
                                        </Border.RenderTransform>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="4"/>
                                                <RowDefinition MaxHeight="{TemplateBinding MaxDropDownHeight}"/>
                                                <RowDefinition Height="1"/>
                                                <RowDefinition Height="1"/>
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>
                                            <Rectangle Grid.Row="0"
                                                Margin="0"
                                                Height="4"
                                                HorizontalAlignment="Stretch"
                                                VerticalAlignment="Stretch"
                                                Fill="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMenuBackgroundGradientKey}}"
                                                />
                                            <ListBox x:Name="Selector" Grid.Row="1"
                                                ItemTemplate="{TemplateBinding ItemTemplate}"
                                                ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                                BorderThickness="0"
                                                ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                                ScrollViewer.VerticalScrollBarVisibility="Auto"
                                                     HorizontalContentAlignment="Stretch"
                                                Background="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMenuBackgroundGradientKey}}"
                                                     MinWidth="{Binding ElementName=AutoCompleteSearchBoxBorder, Path=ActualWidth}"
                                                     MaxWidth="{Binding ElementName=AutoCompleteSearchBoxBorder, Path=ActualWidth}"
                                                     HorizontalAlignment="Left"
                                                />
                                            <Rectangle Grid.Row="2"
                                                Margin="0"
                                                Height="1"
                                                HorizontalAlignment="Stretch"
                                                VerticalAlignment="Stretch"
                                                Fill="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMenuBackgroundGradientKey}}"
                                                />
                                            <Rectangle Grid.Row="3" x:Name="ClearSearchHistorySeparator"
                                                Margin="0"
                                                Height="1"
                                                HorizontalAlignment="Stretch"
                                                VerticalAlignment="Bottom"
                                                Fill="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMenuSeparatorKey}}"
                                                />
                                            <TextBlock Grid.Row="4" x:Name="ClearSearchHistoryText"
                                                       Padding="3,3,0,3" MouseDown="TextBlock_MouseDown"
                                                       >
                                                    <Run FontFamily="pack://application:,,,/UI;component/Resources/#FontAwesome" Text="&#xf00d;"/>
                                                    <Run/>
                                                    <Run>Clear Search History</Run>
                                                <TextBlock.Style>
                                                    <Style TargetType="{x:Type TextBlock}">
                                                        <Setter Property="Background" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarMenuBackgroundGradientKey}}"/>
                                                        <Setter Property="Foreground" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarTextActiveKey}}"/>
                                                        <Style.Triggers>
                                                            <Trigger Property="IsMouseOver" Value="True">
                                                                <Setter Property="Foreground" Value="{DynamicResource {x:Static vsfx:VsBrushes.HelpSearchResultLinkSelectedKey}}"/>
                                                                <Setter Property="TextDecorations" Value="Underline"/>
                                                            </Trigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </TextBlock.Style>
                                            </TextBlock>
                                        </Grid>
                                    </Border>
                                </Grid>
                            </Popup>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="AutoCompleteSearchBoxBorder" Property="BorderBrush" Value="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarHoverOverSelectedIconBorderKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </controls:AutoCompleteBox.Template>
            </controls:AutoCompleteBox>
        </Grid>
            
        <Popup Name="SearchBoxTooltip" PlacementTarget="{Binding ElementName=SearchBox}" Placement="Left"
                        AllowsTransparency="True">
            <Border BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.FileTabBorderKey}}" BorderThickness="1,1,1,1">
                <StackPanel Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}">
                    <StackPanel.Resources>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}"/>
                            <Setter Property="Margin" Value="6,6,6,0"/>
                        </Style>
                    </StackPanel.Resources>
                    <TextBlock>
                        <Run FontFamily="Arial">Add ALL relevant words (i.e., Google-style query)</Run>
                    </TextBlock>
                    <TextBlock>
                        <Run FontFamily="Arial">Put exact phrases in quotes:</Run> <Run FontFamily="Courier New">"void StartMonitor("</Run>
                    </TextBlock>
                    <TextBlock>
                        <Run FontFamily="Arial">Escape \ and " in quotes:</Run> <Run FontFamily="Courier New">"OpenFile(\"file.txt\");"</Run>
                    </TextBlock>
                    <TextBlock>
                        <Run FontFamily="Arial">Put '-' before unwanted words:</Run> <Run FontFamily="Courier New">parse method -test</Run>
                    </TextBlock>
                    <TextBlock>
                        <Run FontFamily="Arial">Filter results by file extensions:</Run> <Run FontFamily="Courier New">image file:cs</Run>
                    </TextBlock>
                    <Rectangle Height="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,4,0,0" Fill="{DynamicResource {x:Static vsfx:VsBrushes.FileTabBorderKey}}"/>
                    <CheckBox Margin="6,0,0,3" Name="SearchBoxTooltipNoShow" IsEnabled="True" Checked="SearchBoxTooltipNoShow_Checked">
                        <Run FontFamily="Arial">Don't show again. Get query tips in Help (?).</Run>
                    </CheckBox>
                </StackPanel>
            </Border>
        </Popup>

        <ProgressBar Margin="5,2,5,0" Name="ProgBar" Grid.Row="2"
                 VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="3" IsIndeterminate="True" Visibility="{Binding ProgressBarVisibility}"/>

        <!-- info string -->
        <TextBlock Margin="6,0,0,0" Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}" 
                 Name = "SearchStatusTextBlock"
                 FontSize="11" FontStyle="Italic" Background="{Binding Path=Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" 
                 Grid.Row="3" Width="Auto" HorizontalAlignment="Stretch"  
                 Grid.Column="0" Height="Auto"
                 KeyboardNavigation.IsTabStop="False" TextWrapping="Wrap" />

        <!-- info string -->
        <TextBlock Margin="6,0,0,0" Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}" FontSize="11" 
                Name="RecommendedQueryTextBlock"
                FontStyle="Italic" Background="{Binding Path=Background, 
                RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" 
                Grid.Row="4" Width="Auto" HorizontalAlignment="Stretch"  
                 Height="15" 
                KeyboardNavigation.IsTabStop="False" TextWrapping="Wrap"></TextBlock>



        <Popup Name="TagCloudPopUpWindow" Placement="Center" StaysOpen="False" IsOpen="False" Width="900" IsEnabled="True" 
               Grid.Row="3">
            <StackPanel Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}">
                <DockPanel Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}" Margin="0,0,0,0" HorizontalAlignment="Center">
                    <Button Name="previousTagButton"  Margin="0,0,0,0" Width="20" HorizontalAlignment="Right"
                        FontFamily="ExtraBold" IsEnabled="True"
        		        KeyboardNavigation.IsTabStop="False" Style="{DynamicResource ToggleButtonStyleBorderless}" 
                        Click="ChangeSelectedTag" FontWeight="ExtraBold" Height="40" VerticalAlignment="Top" 
                        ToolTip="Previous Word" Content="&lt;" FontSize="30" Foreground="CadetBlue">
                    </Button>
                    <TextBlock Name="tagCloudTitleTextBlock" Margin="0,0,0,0" Visibility="Visible" IsEnabled="True" 
                                HorizontalAlignment="Stretch" Foreground="CadetBlue"
                               Background = "{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}" 
                               FontSize="28" FontFamily="Times">
                    </TextBlock>

                    <Button Name="nextTagButton"  Margin="0,0,0,0" Width="20" HorizontalAlignment="Left"
                        FontFamily="ExtraBold" IsEnabled="True" FontSize="30" Foreground="CadetBlue"
        		        KeyboardNavigation.IsTabStop="False" Style="{DynamicResource ToggleButtonStyleBorderless}" 
                        Click="ChangeSelectedTag" FontWeight="ExtraBold" Height="40" VerticalAlignment="Top" 
                        Background = "{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}" 
                        ToolTip="Next word" Content="&gt;">
                    </Button>
                </DockPanel>
                <TextBlock Margin="0,0,0,0" Name="TagCloudTextBlock" IsEnabled="True" 
                           Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}" 
                           HorizontalAlignment="Stretch" 
                    TextWrapping="Wrap" FontFamily="Times">
                </TextBlock>
            </StackPanel>
        </Popup>

        <!-- details -->
        <Expander Grid.Row="5" Margin="5" Grid.Column="0" Name="LayoutRoot">
            <Expander.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}"  Text="Advanced Options" />
                    </StackPanel>
                </DataTemplate>
            </Expander.HeaderTemplate>
            <Border CornerRadius="5" BorderThickness="1" BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}" Margin="0,3,0,0">
                <StackPanel Margin="5">
                    <!--Access Level-->
                    <Expander>
                        <Expander.Header>
                            <TextBlock Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}"  Text="Access level" Grid.Row="0" Grid.ColumnSpan="2"/>
                        </Expander.Header>
                        <Expander.Content>
                            <ListBox Margin="5,3,5,5" ItemsSource="{Binding AccessLevels}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <CheckBox Width="20" IsChecked="{Binding Path=Checked}"
                                               />
                                            <TextBlock 
                                       Width="100" Text="{Binding Path=Access}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Expander.Content>
                    </Expander>
                    <!--Program Element Type-->
                    <Expander>
                        <Expander.Header>
                            <TextBlock Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}" Text="Element type" Grid.Row="0"/>
                        </Expander.Header>
                        <Expander.Content>
                            <ListBox Margin="5,3,5,5" ItemsSource="{Binding ProgramElements}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <CheckBox Width="20" IsChecked="{Binding Path=Checked}"
                                               />
                                            <TextBlock 
                                       Width="100" Text="{Binding Path=ProgramElement}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Expander.Content>
                    </Expander>

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="212*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <!--<CheckBox Name="isExactMode" Content="Exact mode" IsChecked="{Binding Path=SearchCriteria.ExactMode, Mode=TwoWay}" Grid.Row="0" Grid.Column="0" Margin="4,4,4,4" KeyboardNavigation.IsTabStop="True" KeyboardNavigation.TabIndex="51" />
                    <CheckBox Name="isMatchCase" Content="Match Case" IsChecked="{Binding Path=SearchCriteria.MatchCase, Mode=TwoWay}" Grid.Column="2" Margin="4,4,4,4" KeyboardNavigation.IsTabStop="True" KeyboardNavigation.TabIndex="53" />
                    -->
                    </Grid>

                    <!-- Reset -->
                    <Grid HorizontalAlignment="Left" Width="276">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Button Grid.Column="0" Name="Reset"  Margin="5,5,0,0" FontFamily="ExtraBold" IsEnabled="True" 
                                KeyboardNavigation.IsTabStop="False" Height="23" Width="120" 
                                VerticalAlignment="Top" ToolTip="Reset Sando Index"
                                Command="{Binding ResetCommand}">Reset Sando Index
                        </Button>
                        <Button Grid.Column="1" Name="OpenLog"  Margin="10,5,0,0" FontFamily="ExtraBold" IsEnabled="True" 
                        	KeyboardNavigation.IsTabStop="False" Height="23" Width="120" 
                        	VerticalAlignment="Top" ToolTip="Open Sando's Error Log"
                        	Command="{Binding OpenLogCommand}" Content="Open Error Log"/>
                        <!--Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}"-->

                    </Grid>

                </StackPanel>
            </Border>
        </Expander>
      
    </Grid>
</UserControl>
